package com.threeox.commonlibrary.ui.view.inter.engine.model;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.threeox.commonlibrary.entity.engine.model.layout.CommandMsg;
import com.threeox.commonlibrary.entity.engine.request.RequestMsg;
import com.threeox.commonlibrary.entity.engine.request.base.BaseRequestMsg;
import com.threeox.commonlibrary.ui.view.engineview.model.ModelBaseView;
import com.threeox.commonlibrary.ui.view.inter.engine.base.IBaseExtend;

/**
 *
 * @ClassName: IModelExtend
 *
 * @Description: Todo(模型的扩展实现接口)
 *
 * @author 赵屈犇
 *
 * @date 创建时间:2016/12/20 17:06 
 * 
 * @version 1.0
 */
public interface IModelExtend<T> extends IBaseExtend {

    /**
     * 模型View中的初始化
     *
     * @param context
     * @param modelBaseView
     */
    void init(Context context, ModelBaseView modelBaseView);

    /**
     * 在请求之前调用
     *
     * @param requestMsg
     * @return  true 就是不拦截,false 就是拦截
     */
    boolean onBeforeExecRequest(RequestMsg requestMsg);

    /**
     * 在请求成功之前，没有解析和注入数据之前调用
     *
     * @param requestMsg
     * @param url
     * @param id
     * @param msg
     * @param data
     * @return  true 就是不拦截,false 就是拦截
     */
    boolean onBeforeRequestSuccess(BaseRequestMsg requestMsg, String url, int id, String msg, T data);

    /**
     * 在请求数据成功之后，解析和注入数据之后调用
     *
     * @param requestMsg
     * @param url
     * @param id
     * @param msg
     * @param data
     */
    void onAfterRequestSuccess(BaseRequestMsg requestMsg, String url, int id, String msg, T data);

    /**
     * 命令按钮操作之前的接口
     *
     * @param requestMsg
     * @param commandmsg
     * @param data
     * @return
     * @throws Exception
     */
    boolean onBeforeCommand(RequestMsg requestMsg, CommandMsg commandmsg, JSONObject data) throws Exception;


    /**
     * 命令按钮操作之后的接口
     *
     * @param commandtype
     * @param commandmsg
     * @param data
     * @return
     */
    boolean onAfterCommand(RequestMsg commandtype, CommandMsg commandmsg, JSONObject data);

}
